using System;
using System.Collections;
using Sedna.Core.Controller.Configurations;
using Sedna.Core.Controls;
using Sedna.Core.Controls.Support;
using Sedna.Core.Controls.Support.Javascript;
using Sedna.Util;

namespace Sedna.Core.Controller
{
	/// <summary>
	/// Base class for popups.
	/// </summary>
	public class PopupPage: BasePage
	{
		//private const string parameterName="popupParameter";

		protected override void OnInit(EventArgs e)
		{
			base.OnInit(e);			
//			ArrayList parameters=LoadPopupParameters();
			
			//Non-modal version
			string controlVar=Request.QueryString["controlVar"];


            JavascriptController.Current.DeclareClass("PopupPage");
            JavascriptController.Current.DeclareObject("popup", "PopupPage", controlVar != null && !String.Empty.Equals(controlVar) ? "opener." + controlVar : "null" /*, JavascriptUtil.ArrayDeclaration(parameters)*/);

		    if (!Utility.IsNullOrEmpty(Request.QueryString["workflowId"]))
		    {
                WorkflowId = Request.QueryString["workflowId"];
		    }
/*
			if (controlVar!=null && controlVar!=String.Empty)
			{

				IDynamicContentGenerator onReturnJavascriptGenerator=(IDynamicContentGenerator)ClientScriptingConfiguration.JavascriptGenerators["onreturn"];
				IDictionary parameters=new Hashtable();
				parameters.Add("popup.populate.object", controlVar);

				Page.RegisterClientScriptBlock(javascriptKey, "<script>"+onReturnJavascriptGenerator.Generate(Context, parameters)+"</script>");



			}
*/
			
		}

/*
		private ArrayList LoadPopupParameters()
		{
			ArrayList parameters=new ArrayList(3);
			for (int i=0;;i++)
			{
				string parameter=Request.QueryString[parameterName+i];
				if (parameter!=null)
				{
					parameters.Add(parameter);
				}
				else
				{
					break;
				}
			}
			ExecutionContext.Add("popup.parameters", parameters);
			return parameters;
		}
*/
	}
}
